﻿
#include "pch.h"
#include "AtCodeMaster.h"
#include "afxdialogex.h"
#include "CFiltration.h"
#include <regex>
#include <iostream>
//#include <boost/regex.hpp>
#include <boost/regex/v5/regex.hpp>     //正则表达式
#include "Other.h"
#include "AtCodeMasterDlg.h"
using namespace std;
CString EditCodeMin;    //最小长度临时存放
CString EditCodeMax;    //最大长度临时存放
CString RegExp[8];      //单个正则
CString RegExpStr;      //整体正则

IMPLEMENT_DYNAMIC(CFiltration, CDialogEx)

CFiltration::CFiltration(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_Filtration, pParent)
{
}

CFiltration::~CFiltration()
{
}

// 消息处理程序，初始化
BOOL CFiltration::OnInitDialog()
{

    CDialog::OnInitDialog();
    int MaxPath = 10240;    //缓存大小

    AppPath = Oth.GetAppPath(); //获取根目录
    ConfigPath = AppPath + L"Setting/Config.ini";
    CString CStr;      //读取字符串 
    int Check;              //读取int类型    
    OnBnClickedFold0();             //折叠对话框的右边
    CRect rect;                     //获取窗口位置坐标
    GetClientRect(&rect);           //取客户区大小
    old.x = rect.right - rect.left; //Point old,用于记录窗口原始坐标
    old.y = rect.bottom - rect.top; //Point old,用于记录窗口原始坐标

    //测试
    GetPrivateProfileString(_T("Edit"), _T("Test"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    ((CEdit*)GetDlgItem(IDC_EDITCODETEST))->SetWindowText(CStr);//测试
    CStr.ReleaseBuffer();
    //生成正则
    GetPrivateProfileString(_T("Check"), _T("Length"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    Check = _ttoi(CStr);
    ((CButton*)GetDlgItem(IDC_CHECKLENGTH))->SetCheck(Check);//长度
    GetPrivateProfileString(_T("Check"), _T("MustConTain"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    Check = _ttoi(CStr);
    ((CButton*)GetDlgItem(IDC_CHECKMUSTCONTAIN))->SetCheck(Check);//必须包含
    GetPrivateProfileString(_T("Check"), _T("CantContain"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    Check = _ttoi(CStr);
    ((CButton*)GetDlgItem(IDC_CHECKCANTCONTAIN))->SetCheck(Check);//不能包含
    GetPrivateProfileString(_T("Check"), _T("Top"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    Check = _ttoi(CStr);
    ((CButton*)GetDlgItem(IDC_CHECKTOP))->SetCheck(Check);//开头
    GetPrivateProfileString(_T("Check"), _T("End"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    Check = _ttoi(CStr);
    ((CButton*)GetDlgItem(IDC_CHECKEND))->SetCheck(Check);//结尾
    GetPrivateProfileString(_T("Check"), _T("Rule"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    Check = _ttoi(CStr);
    ((CButton*)GetDlgItem(IDC_CHECKBOXRULE))->SetCheck(Check);//字符要求
    //Radio
    GetPrivateProfileString(_T("Radio"), _T("RadioFigure"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    Check = _ttoi(CStr);
    ((CButton*)GetDlgItem(IDC_RADIOFIGURE))->SetCheck(Check);//全数字
    GetPrivateProfileString(_T("Radio"), _T("RadioLetter"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    Check = _ttoi(CStr);
    ((CButton*)GetDlgItem(IDC_RADIOLETTER))->SetCheck(Check);//全字母
    GetPrivateProfileString(_T("Radio"), _T("RadioAll"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    Check = _ttoi(CStr);
    ((CButton*)GetDlgItem(IDC_RADIOALL))->SetCheck(Check);//数字和字母

    //Edit
    GetPrivateProfileString(_T("Edit"), _T("Min"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    ((CEdit*)GetDlgItem(IDC_EDITCODEMIN))->SetWindowText(CStr); //最小长度
    GetPrivateProfileString(_T("Edit"), _T("Max"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    ((CEdit*)GetDlgItem(IDC_EDITCODEMAX))->SetWindowText(CStr); //最大长度
    GetPrivateProfileString(_T("Edit"), _T("CantContain"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    ((CEdit*)GetDlgItem(IDC_EDITCANTCONTAIN))->SetWindowText(CStr); //不能包含
    GetPrivateProfileString(_T("Edit"), _T("MustConTain"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    ((CEdit*)GetDlgItem(IDC_EDITMUSTCONTAIN))->SetWindowText(CStr); //必须包含
    GetPrivateProfileString(_T("Edit"), _T("Top"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    ((CEdit*)GetDlgItem(IDC_EDITCODETOP))->SetWindowText(CStr); //开头
    GetPrivateProfileString(_T("Edit"), _T("CodeEnd"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    ((CEdit*)GetDlgItem(IDC_EDITCODEEND))->SetWindowText(CStr); //结尾
    //RegExp[0] = "^";
    //RegExp[7] = "$";
    //GetPrivateProfileString(_T("Edit"), _T("CantRegExp"), CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini");
    //((CEdit*)GetDlgItem(IDC_EDITREGEXP))->SetWindowText(CStr); //生成正则

    //GetPrivateProfileString(_T("Edit"), _T("RegExp"), CString("NULL"), RegExpStr.GetBuffer(MaxPath), MaxPath, Oth.GetAppPath() + L"Setting/Config.ini"); //最终正则
    //RegExpStr.ReleaseBuffer();

    //自定义
    //勾选
    GetPrivateProfileString(L"Filtration", L"IDC_Check_Filtration1", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CButton*)GetDlgItem(IDC_Check_Filtration1))->SetCheck(_ttoi(CStr));
    GetPrivateProfileString(L"Filtration", L"IDC_Check_Filtration2", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CButton*)GetDlgItem(IDC_Check_Filtration2))->SetCheck(_ttoi(CStr));
    GetPrivateProfileString(L"Filtration", L"IDC_Check_Filtration3", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CButton*)GetDlgItem(IDC_Check_Filtration3))->SetCheck(_ttoi(CStr));
    GetPrivateProfileString(L"Filtration", L"IDC_Check_Filtration4", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CButton*)GetDlgItem(IDC_Check_Filtration4))->SetCheck(_ttoi(CStr));
    GetPrivateProfileString(L"Filtration", L"IDC_Check_Filtration5", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CButton*)GetDlgItem(IDC_Check_Filtration5))->SetCheck(_ttoi(CStr));
    GetPrivateProfileString(L"Filtration", L"IDC_Check_Filtration6", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CButton*)GetDlgItem(IDC_Check_Filtration6))->SetCheck(_ttoi(CStr));
    GetPrivateProfileString(L"Filtration", L"IDC_Check_Filtration7", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CButton*)GetDlgItem(IDC_Check_Filtration7))->SetCheck(_ttoi(CStr));
    GetPrivateProfileString(L"Filtration", L"IDC_Check_Filtration8", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CButton*)GetDlgItem(IDC_Check_Filtration8))->SetCheck(_ttoi(CStr));
    GetPrivateProfileString(L"Filtration", L"IDC_Check_Filtration9", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CButton*)GetDlgItem(IDC_Check_Filtration9))->SetCheck(_ttoi(CStr));

    GetPrivateProfileString(L"Filtration", L"IDC_Check_Filtration21", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CButton*)GetDlgItem(IDC_Check_Filtration21))->SetCheck(_ttoi(CStr));
    //名称
    GetPrivateProfileString(L"Filtration", L"IDC_Name_Filtration1", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Name_Filtration1))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Name_Filtration2", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Name_Filtration2))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Name_Filtration3", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Name_Filtration3))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Name_Filtration4", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Name_Filtration4))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Name_Filtration5", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Name_Filtration5))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Name_Filtration6", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Name_Filtration6))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Name_Filtration7", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Name_Filtration7))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Name_Filtration8", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Name_Filtration8))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Name_Filtration9", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Name_Filtration9))->SetWindowText(CStr);

    GetPrivateProfileString(L"Filtration", L"IDC_Name_Filtration21", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Name_Filtration21))->SetWindowText(CStr);
    //标志
    GetPrivateProfileString(L"Filtration", L"IDC_Key_Filtration1", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Key_Filtration1))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Key_Filtration2", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Key_Filtration2))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Key_Filtration3", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Key_Filtration3))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Key_Filtration4", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Key_Filtration4))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Key_Filtration5", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Key_Filtration5))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Key_Filtration6", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Key_Filtration6))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Key_Filtration7", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Key_Filtration7))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Key_Filtration8", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Key_Filtration8))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_Key_Filtration9", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Key_Filtration9))->SetWindowText(CStr);

    GetPrivateProfileString(L"Filtration", L"IDC_Key_Filtration21", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Key_Filtration21))->SetWindowText(CStr);
    //内容
    GetPrivateProfileString(L"Filtration", L"IDC_RegExp_Filtration1", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_RegExp_Filtration1))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_RegExp_Filtration2", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_RegExp_Filtration2))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_RegExp_Filtration3", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_RegExp_Filtration3))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_RegExp_Filtration4", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_RegExp_Filtration4))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_RegExp_Filtration5", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_RegExp_Filtration5))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_RegExp_Filtration6", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_RegExp_Filtration6))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_RegExp_Filtration7", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_RegExp_Filtration7))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_RegExp_Filtration8", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_RegExp_Filtration8))->SetWindowText(CStr);
    GetPrivateProfileString(L"Filtration", L"IDC_RegExp_Filtration9", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_RegExp_Filtration9))->SetWindowText(CStr);
 
    GetPrivateProfileString(L"Filtration", L"IDC_RegExp_Filtration21", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_RegExp_Filtration21))->SetWindowText(CStr);

    //中通自动获取
    GetPrivateProfileString(L"FiltrationAuto", L"IDC_Check_FiltrationAuto2", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CButton*)GetDlgItem(IDC_Check_FiltrationAuto2))->SetCheck(_ttoi(CStr));
    GetPrivateProfileString(L"FiltrationAuto", L"IDC_Edit_FiltrationAppId2", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath); ((CEdit*)GetDlgItem(IDC_Edit_FiltrationAppId2))->SetWindowText(CStr);
    GetPrivateProfileString(L"FiltrationAuto", L"IDC_Edit_FiltrationKey2", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath);  ((CEdit*)GetDlgItem(IDC_Edit_FiltrationKey2))->SetWindowText(CStr);
    GetPrivateProfileString(L"FiltrationAuto", L"IDC_Edit_FiltrationUrl2", CString("NULL"), CStr.GetBuffer(MaxPath), MaxPath, ConfigPath);  ((CEdit*)GetDlgItem(IDC_Edit_FiltrationUrl2))->SetWindowText(CStr);

     
    return TRUE;
}
//^(80_H1)[0-9]{10}$|^(80_H5)[0-9]{10}$|^(80_D)[0-9]{11}$|^(80_DD)[0-9]{10}$|^(80_Z)[0-9]{11}$|^(80_B)[0-9]{11}$|^(80_V)[0-9]{11}$|^(80_C)[0-9]{11}$|^(80_M)[0-9]{11}$|^(80_6)[0-9]{17}$|^(80_7)[0-9]{17}$|^(80_8)[0-9]{17}$|^(80_DD)[0-9]{16}$|^(80_G)[0-9]{11}$|^(80_G9)[0-9]{10}$|^(80_G001)[0-9]{8}$|^(80_G)[0-9]{17}$|^(80_B9)[0-9]{10}$|^(80_DB9)[0-9]{9}$|^(80_99)[0-9]{16}$|^(80_R02T)[0-9]{12}$|^(80_R02T)[0-9]{18}$|^(80_R02TDD)[0-9]{10}$|^(80_R02TDD)[0-9]{16}$|^(80_YT)[0-9]{13}$|^(80_R02Z)[0-9]{18}$|^(80_R02Z)[0-9]{12}$|^(80_R02TYT)[0-9]{13}$|^(80_R02ZG)[0-9]{17}$|^(80_YTG)[0-9]{12}$|^(80_YTD)[0-9]{12}$|^(80_R02Z)[0-9]{15}$|^(80_R02ZYT)[0-9]{13}$

void CFiltration::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_EDITCODETEST, MsgEditCodeTest);  // 测试 
    DDX_Text(pDX, IDC_EDITCODEMIN, m_strCodeMin);  //输入框 - 最小长度
    DDX_Text(pDX, IDC_EDITCODEMAX, m_strCodeMax);  //输入框 - 最大长度
    DDX_Text(pDX, IDC_EDITCODETOP, m_strCodeTop);  //输入框 - 开头
    DDX_Text(pDX, IDC_EDITCODEEND, m_strCodeEnd);  //输入框 - 结尾
    DDX_Text(pDX, IDC_EDITMUSTCONTAIN, m_strCodeMustConTain);  //输入框 - 必须包含
    DDX_Text(pDX, IDC_EDITCANTCONTAIN, m_strCodeCantContain);  //输入框 - 不能包含
    DDX_Text(pDX, IDC_EDITCODETEST, m_strCodeTest);  //输入框 - 条码测试 
    DDX_Control(pDX, IDC_EDITCODEMIN, MsgEditCodeMin);  // 最小长度 
    DDX_Control(pDX, IDC_EDITCODEMAX, MsgEditCodeMax);  // 最大长度
    DDX_Control(pDX, IDC_EDITCODETOP, MsgEditCodeTop);  // 开头
    DDX_Control(pDX, IDC_EDITCODEEND, MsgEditCodeEnd);  // 结尾
    DDX_Control(pDX, IDC_EDITMUSTCONTAIN, MsgEditCodeMustConTain);  // 必须包含
    DDX_Control(pDX, IDC_EDITCANTCONTAIN, MsgEditCodeCantContain);  // 不能包含
    DDX_Control(pDX, IDC_RegExp_Filtration21, MsgEditCodeRegExp);  // 正则表达式
    //DDX_Text(pDX, IDC_EDITREGEXP, m_strCodeRegExp);  //输入框 - 正则表达式
}

BEGIN_MESSAGE_MAP(CFiltration, CDialogEx)
    ON_EN_CHANGE(IDC_EDITCODETEST, &CFiltration::OnEnChangeEditcodetest)
    ON_EN_CHANGE(IDC_EDITCANTCONTAIN, &CFiltration::OnEnChangeEditcantcontain)
    ON_EN_CHANGE(IDC_EDITMUSTCONTAIN, &CFiltration::OnEnChangeEditmustcontain)
    ON_EN_CHANGE(IDC_EDITCODEEND, &CFiltration::OnEnChangeEditcodeend)
    ON_EN_CHANGE(IDC_EDITCODEMAX, &CFiltration::OnEnChangeEditcodemax)
    ON_EN_CHANGE(IDC_EDITCODETOP, &CFiltration::OnEnChangeEditcodetop)
    ON_EN_CHANGE(IDC_EDITCODEMIN, &CFiltration::OnEnChangeEditcodemin)
    ON_BN_CLICKED(IDC_RADIOFIGURE, &CFiltration::OnBnClickedRadiofigure)
    ON_BN_CLICKED(IDC_RADIOLETTER, &CFiltration::OnBnClickedRadioletter)
    ON_BN_CLICKED(IDC_RADIOALL, &CFiltration::OnBnClickedRadioall)
    ON_BN_CLICKED(IDC_CHECKLENGTH, &CFiltration::OnBnClickedChecklength)
    ON_BN_CLICKED(IDC_CHECKTOP, &CFiltration::OnBnClickedChecktop)
    ON_BN_CLICKED(IDC_CHECKEND, &CFiltration::OnBnClickedCheckend)
    ON_BN_CLICKED(IDC_CHECKMUSTCONTAIN, &CFiltration::OnBnClickedCheckmustcontain)
    ON_BN_CLICKED(IDC_CHECKCANTCONTAIN, &CFiltration::OnBnClickedCheckcantcontain)
    ON_BN_CLICKED(IDC_CHECKBOXRULE, &CFiltration::OnBnClickedCheckboxrule)
    ON_BN_CLICKED(IDC_BtnSave, &CFiltration::OnBnClickedBtnsave)
    ON_WM_DESTROY()
    ON_WM_CTLCOLOR() 
    ON_BN_CLICKED(IDC_Fold0, &CFiltration::OnBnClickedFold0)
    ON_WM_SIZE()
    ON_EN_CHANGE(IDC_Name_Filtration1, &CFiltration::OnEnChangeNameFiltration1)
    ON_EN_CHANGE(IDC_Key_Filtration1, &CFiltration::OnEnChangeKeyFiltration1)
    ON_EN_CHANGE(IDC_Name_Filtration2, &CFiltration::OnEnChangeNameFiltration2)
    ON_EN_CHANGE(IDC_Name_Filtration3, &CFiltration::OnEnChangeNameFiltration3)
    ON_EN_CHANGE(IDC_Name_Filtration4, &CFiltration::OnEnChangeNameFiltration4)
    ON_EN_CHANGE(IDC_Name_Filtration5, &CFiltration::OnEnChangeNameFiltration5)
    ON_EN_CHANGE(IDC_Name_Filtration6, &CFiltration::OnEnChangeNameFiltration6)
    ON_EN_CHANGE(IDC_Name_Filtration7, &CFiltration::OnEnChangeNameFiltration7)
    ON_EN_CHANGE(IDC_Name_Filtration8, &CFiltration::OnEnChangeNameFiltration8)
    ON_EN_CHANGE(IDC_Name_Filtration9, &CFiltration::OnEnChangeNameFiltration9)
    ON_EN_CHANGE(IDC_Key_Filtration2, &CFiltration::OnEnChangeKeyFiltration2)
    ON_EN_CHANGE(IDC_Key_Filtration3, &CFiltration::OnEnChangeKeyFiltration3)
    ON_EN_CHANGE(IDC_Key_Filtration4, &CFiltration::OnEnChangeKeyFiltration4)
    ON_EN_CHANGE(IDC_Key_Filtration5, &CFiltration::OnEnChangeKeyFiltration5)
    ON_EN_CHANGE(IDC_Key_Filtration6, &CFiltration::OnEnChangeKeyFiltration6)
    ON_EN_CHANGE(IDC_Key_Filtration7, &CFiltration::OnEnChangeKeyFiltration7)
    ON_EN_CHANGE(IDC_Key_Filtration8, &CFiltration::OnEnChangeKeyFiltration8)
    ON_EN_CHANGE(IDC_Key_Filtration9, &CFiltration::OnEnChangeKeyFiltration9)
    ON_BN_CLICKED(IDC_Check_Filtration1, &CFiltration::OnBnClickedCheckFiltration1)
    ON_BN_CLICKED(IDC_Check_Filtration2, &CFiltration::OnBnClickedCheckFiltration2)
    ON_BN_CLICKED(IDC_Check_Filtration3, &CFiltration::OnBnClickedCheckFiltration3)
    ON_BN_CLICKED(IDC_Check_Filtration4, &CFiltration::OnBnClickedCheckFiltration4)
    ON_BN_CLICKED(IDC_Check_Filtration5, &CFiltration::OnBnClickedCheckFiltration5)
    ON_BN_CLICKED(IDC_Check_Filtration6, &CFiltration::OnBnClickedCheckFiltration6)
    ON_BN_CLICKED(IDC_Check_Filtration7, &CFiltration::OnBnClickedCheckFiltration7)
    ON_BN_CLICKED(IDC_Check_Filtration8, &CFiltration::OnBnClickedCheckFiltration8)
    ON_BN_CLICKED(IDC_Check_Filtration9, &CFiltration::OnBnClickedCheckFiltration9)
    ON_EN_CHANGE(IDC_RegExp_Filtration1, &CFiltration::OnEnChangeRegexpFiltration1)
    ON_EN_CHANGE(IDC_RegExp_Filtration2, &CFiltration::OnEnChangeRegexpFiltration2)
    ON_EN_CHANGE(IDC_RegExp_Filtration3, &CFiltration::OnEnChangeRegexpFiltration3)
    ON_EN_CHANGE(IDC_RegExp_Filtration4, &CFiltration::OnEnChangeRegexpFiltration4)
    ON_EN_CHANGE(IDC_RegExp_Filtration5, &CFiltration::OnEnChangeRegexpFiltration5)
    ON_EN_CHANGE(IDC_RegExp_Filtration6, &CFiltration::OnEnChangeRegexpFiltration6)
    ON_EN_CHANGE(IDC_RegExp_Filtration7, &CFiltration::OnEnChangeRegexpFiltration7)
    ON_EN_CHANGE(IDC_RegExp_Filtration8, &CFiltration::OnEnChangeRegexpFiltration8)
    ON_EN_CHANGE(IDC_RegExp_Filtration9, &CFiltration::OnEnChangeRegexpFiltration9)
    ON_BN_CLICKED(IDC_Check_FiltrationAuto2, &CFiltration::OnBnClickedCheckFiltrationauto2)
    ON_EN_CHANGE(IDC_Edit_FiltrationAppId2, &CFiltration::OnEnChangeEditFiltrationappid2)
    ON_EN_CHANGE(IDC_Edit_FiltrationKey2, &CFiltration::OnEnChangeEditFiltrationkey2)
    ON_EN_CHANGE(IDC_Edit_FiltrationUrl2, &CFiltration::OnEnChangeEditFiltrationurl2) 
    ON_EN_CHANGE(IDC_RegExp_Filtration21, &CFiltration::OnEnChangeRegexpFiltration21)
    ON_BN_CLICKED(IDC_Check_Filtration21, &CFiltration::OnBnClickedCheckFiltration21)
    ON_EN_CHANGE(IDC_Name_Filtration21, &CFiltration::OnEnChangeNameFiltration21)
    ON_EN_CHANGE(IDC_Key_Filtration21, &CFiltration::OnEnChangeKeyFiltration21)
END_MESSAGE_MAP()

// 字体颜色
HBRUSH CFiltration::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
    if (IDC_STATICRESULT == pWnd->GetDlgCtrlID())
    {
        if (TRUE == Color_Blue)
        {
            pDC->SetTextColor(RGB(0, 0, 255));	//蓝色
        }
        else if (TRUE == Color_Red)
        {
            pDC->SetTextColor(RGB(255, 0, 0));	//红色		
        }
        else
        {
            pDC->SetTextColor(RGB(0, 0, 0));
        }
    }
    return hbr;
}

//勾选框 - 字符要求
void CFiltration::OnBnClickedCheckboxrule()
{
    if ((((CButton*)GetDlgItem(IDC_CHECKBOXRULE))->GetCheck() == 1))
    { 
        if (((CButton*)GetDlgItem(IDC_RADIOFIGURE))->GetCheck())
        {
            RegExpStr = "";
            RegExp[1] = "(?=[0-9]+$)";
            for (int i = 0; i < 8; i++)
            {
                RegExpStr += RegExp[i];
            }
            MsgEditCodeRegExp.SetWindowText(RegExpStr);
        }
        else if (((CButton*)GetDlgItem(IDC_RADIOLETTER))->GetCheck())
        {
            RegExpStr = "";
            RegExp[1] = "(?=[A-Za-z]+$)";
            for (int i = 0; i < 8; i++)
            {
                RegExpStr += RegExp[i];
            }
            MsgEditCodeRegExp.SetWindowText(RegExpStr);
        }
        else if (((CButton*)GetDlgItem(IDC_RADIOALL))->GetCheck())
        {
            RegExpStr = "";
            RegExp[1] = "(?=[A-Za-z0-9]+$)";
            for (int i = 0; i < 8; i++)
            {
                RegExpStr += RegExp[i];
            }
        }
    }
    else
    {
        RegExpStr = "";
        RegExp[1] = "";
        for (int i = 0; i < 8; i++)
        {
            RegExpStr += RegExp[i];
        }
    }
    MsgEditCodeRegExp.SetWindowText(RegExpStr);
}
//单选框 - 字符要求
void CFiltration::OnBnClickedRadiofigure()
{
    OnBnClickedCheckboxrule();
}
void CFiltration::OnBnClickedRadioletter()
{
    OnBnClickedCheckboxrule();
}
void CFiltration::OnBnClickedRadioall()
{
    OnBnClickedCheckboxrule();
}

//勾选框 - 不能包含
void CFiltration::OnBnClickedCheckcantcontain()
{
    if (((CButton*)GetDlgItem(IDC_CHECKCANTCONTAIN))->GetCheck() == 1)
    {
        ((CEdit*)GetDlgItem(IDC_EDITCANTCONTAIN))->GetWindowText(RegExp[2]); //获取输入框内容 
        RegExpStr = "";
        RegExp[2] = _T("^(?!.*") + RegExp[2] + _T(")");
    }
    else
    {
        RegExpStr = "";
        RegExp[2] = "";
    }
    for (int i = 0; i < 8; i++)
    {
        RegExpStr += RegExp[i];
    }
    MsgEditCodeRegExp.SetWindowText(RegExpStr);
}
//输入框 - 不能包含
void CFiltration::OnEnChangeEditcantcontain()
{
    OnBnClickedCheckcantcontain();
}

//勾选框 - 必须包含
void CFiltration::OnBnClickedCheckmustcontain()
{
    if (((CButton*)GetDlgItem(IDC_CHECKMUSTCONTAIN))->GetCheck() == 1)
    {
        ((CEdit*)GetDlgItem(IDC_EDITMUSTCONTAIN))->GetWindowText(RegExp[3]); //获取输入框内容  
        RegExpStr = "";
        RegExp[3] = _T("(?=.*") + RegExp[3] + _T(")");
    }
    else
    {
        RegExpStr = "";
        RegExp[3] = "";
    }
    for (int i = 0; i < 8; i++)
    {
        RegExpStr += RegExp[i];
    }
    MsgEditCodeRegExp.SetWindowText(RegExpStr);
}
//输入框 - 必须包含
void CFiltration::OnEnChangeEditmustcontain()
{
    OnBnClickedCheckmustcontain();
}

//勾选框 - 开头
void CFiltration::OnBnClickedChecktop()
{
    if (((CButton*)GetDlgItem(IDC_CHECKTOP))->GetCheck() == 1)
    {
        ((CEdit*)GetDlgItem(IDC_EDITCODETOP))->GetWindowText(RegExp[4]); //获取输入框内容  
        RegExpStr = "";
        RegExp[4] = _T("(?=^(") + RegExp[4] + _T(").*)"); //指定开头
    }
    else
    {
        RegExpStr = "";
        RegExp[4] = "";
    }
    for (int i = 0; i < 8; i++)
    {
        RegExpStr += RegExp[i];
    }
    MsgEditCodeRegExp.SetWindowText(RegExpStr);
}
//输入框 - 开头
void CFiltration::OnEnChangeEditcodetop()
{
    OnBnClickedChecktop();
}

//勾选框 - 结尾
void CFiltration::OnBnClickedCheckend()
{
    if (((CButton*)GetDlgItem(IDC_CHECKEND))->GetCheck() == 1)
    {
        ((CEdit*)GetDlgItem(IDC_EDITCODEEND))->GetWindowText(RegExp[5]); //获取输入框内容  
        RegExpStr = "";
        RegExp[5] = _T("(?=.*(") + RegExp[5] + _T(")$)"); //指定结尾
    }
    else
    {
        RegExpStr = "";
        RegExp[5] = "";
    }
    for (int i = 0; i < 8; i++)
    {
        RegExpStr += RegExp[i];
    }
    MsgEditCodeRegExp.SetWindowText(RegExpStr);
}
//输入框 - 结尾
void CFiltration::OnEnChangeEditcodeend()
{
    OnBnClickedCheckend();
}

//勾选框 - 长度
void CFiltration::OnBnClickedChecklength()
{
    if (((CButton*)GetDlgItem(IDC_CHECKLENGTH))->GetCheck() == 1)
    {
        ((CEdit*)GetDlgItem(IDC_EDITCODEMIN))->GetWindowText(EditCodeMin); //获取输入框内容 
        ((CEdit*)GetDlgItem(IDC_EDITCODEMAX))->GetWindowText(EditCodeMax); //获取输入框内容  
        RegExpStr = "";
        RegExp[6] = _T("(.{") + EditCodeMin + _T(",") + EditCodeMax + _T("})");
    }
    else
    {
        RegExpStr = "";
        RegExp[6] = "(.*)";
    }
    for (int i = 0; i < 8; i++)
    {
        RegExpStr += RegExp[i];
    }
    MsgEditCodeRegExp.SetWindowText(RegExpStr);
}
//输入框 - 最小长度
void CFiltration::OnEnChangeEditcodemin()
{
    OnBnClickedChecklength();
}
//输入框 - 最大长度
void CFiltration::OnEnChangeEditcodemax()
{
    OnBnClickedChecklength();
}

#pragma region 是否完全匹配正则式
/// <summary>
/// 测试一个字符串是否完全匹配正则式
/// </summary>
/// <param name="DataStr">需要匹配的字符串</param>
/// <returns>是否匹配</returns>
bool CFiltration::FilteringRule(string Reg, CString Str)
{
    string DataStrTemp = (CStringA)Str; //CString -> string   
    boost::regex reg(Reg);
    return boost::regex_match(DataStrTemp, reg);
}
#pragma endregion

//输入框 - 条码测试
void CFiltration::OnEnChangeEditcodetest()
{
    UpdateData(TRUE);
    AtCodeMasterDlg* ac = (AtCodeMasterDlg*)GetParent(); 
    string regexp; regexp = (CStringA)RegExpStr; regexp += ac->Reg_Exp[0];
    CString CStr;
    ((CEdit*)GetDlgItem(IDC_EDITCODETEST))->GetWindowText(CStr);
    string str; str = CStringA(CStr);
    ac->print_a(3,"正则:%s ",regexp.c_str());
    //if (FilteringRule(regexp, CStr))
    if (boost::regex_match(str, boost::regex(regexp)))
    {
        StatiCresult.CreatePointFont(100, _T("黑体"), NULL); //字体
        GetDlgItem(IDC_STATICRESULT)->SetFont(&StatiCresult);
        Color_Blue = TRUE;    //颜色
        Color_Red = FALSE;
        GetDlgItem(IDC_STATICRESULT)->SetWindowText(_T("验证通过"));
    }
    else
    {
        StatiCresult.CreatePointFont(100, _T("黑体"), NULL); //字体
        GetDlgItem(IDC_STATICRESULT)->SetFont(&StatiCresult);
        Color_Red = TRUE;    //颜色
        Color_Blue = FALSE;
        GetDlgItem(IDC_STATICRESULT)->SetWindowText(_T("验证失败"));
    }
    DeleteObject(StatiCresult);//释放
}


//生成正则
void CFiltration::SaveGetIni()
{
    CString Str;
    CString RadioFigure;//单选框 - 全数字
    CString RadioLetter;//单选框 - 全字母
    CString RadioAll;	//单选框 - 数字和字母
    if (((CButton*)GetDlgItem(IDC_RADIOFIGURE))->GetCheck())
    {
        RadioFigure = "1";
        RadioLetter = "0";
        RadioAll = "0";
    }
    else if (((CButton*)GetDlgItem(IDC_RADIOLETTER))->GetCheck())
    {
        RadioFigure = "0";
        RadioLetter = "1";
        RadioAll = "0";
    }
    else if (((CButton*)GetDlgItem(IDC_RADIOALL))->GetCheck())
    {
        RadioFigure = "0";
        RadioLetter = "0";
        RadioAll = "1";
    }
    WritePrivateProfileStringW(_T("Radio"), _T("RadioFigure"), RadioFigure, Oth.GetAppPath() + L"Setting/Config.ini");  //全数字
    WritePrivateProfileStringW(_T("Radio"), _T("RadioLetter"), RadioLetter, Oth.GetAppPath() + L"Setting/Config.ini");  //全字母
    WritePrivateProfileStringW(_T("Radio"), _T("RadioAll"), RadioAll, Oth.GetAppPath() + L"Setting/Config.ini");		//数字或字母

    if (((CButton*)GetDlgItem(IDC_CHECKLENGTH))->GetCheck() == 1)  //长度
        WritePrivateProfileStringW(_T("Check"), _T("Length"), _T("1"), Oth.GetAppPath() + L"Setting/Config.ini");    
    else
        WritePrivateProfileStringW(_T("Check"), _T("Length"), _T("0"), Oth.GetAppPath() + L"Setting/Config.ini");    

    if ((((CButton*)GetDlgItem(IDC_CHECKBOXRULE))->GetCheck() == 1))	//字符要求
        WritePrivateProfileStringW(_T("Check"), _T("Rule"), _T("1"), Oth.GetAppPath() + L"Setting/Config.ini");   
    else
        WritePrivateProfileStringW(_T("Check"), _T("Rule"), _T("0"), Oth.GetAppPath() + L"Setting/Config.ini");   

    if (((CButton*)GetDlgItem(IDC_CHECKCANTCONTAIN))->GetCheck() == 1)  //不能包含
        WritePrivateProfileStringW(_T("Check"), _T("CantContain"), _T("1"), Oth.GetAppPath() + L"Setting/Config.ini");    
    else
        WritePrivateProfileStringW(_T("Check"), _T("CantContain"), _T("0"), Oth.GetAppPath() + L"Setting/Config.ini");    

    if (((CButton*)GetDlgItem(IDC_CHECKMUSTCONTAIN))->GetCheck() == 1)	//必须包含
        WritePrivateProfileStringW(_T("Check"), _T("MustConTain"), _T("1"), Oth.GetAppPath() + L"Setting/Config.ini");    
    else
        WritePrivateProfileStringW(_T("Check"), _T("MustConTain"), _T("0"), Oth.GetAppPath() + L"Setting/Config.ini");    

    if (((CButton*)GetDlgItem(IDC_CHECKTOP))->GetCheck() == 1)	//开头
        WritePrivateProfileStringW(_T("Check"), _T("Top"), _T("1"), Oth.GetAppPath() + L"Setting/Config.ini");    
    else
        WritePrivateProfileStringW(_T("Check"), _T("Top"), _T("0"), Oth.GetAppPath() + L"Setting/Config.ini");    

    if (((CButton*)GetDlgItem(IDC_CHECKEND))->GetCheck() == 1)	//结尾
        WritePrivateProfileStringW(_T("Check"), _T("End"), _T("1"), Oth.GetAppPath() + L"Setting/Config.ini");     
    else
        WritePrivateProfileStringW(_T("Check"), _T("End"), _T("0"), Oth.GetAppPath() + L"Setting/Config.ini");     

    ((CEdit*)GetDlgItem(IDC_EDITCANTCONTAIN))->GetWindowText(Str); //获取输入框内容 
    WritePrivateProfileStringW(_T("Edit"), _T("CantContain"), Str, Oth.GetAppPath() + L"Setting/Config.ini");  //不能包含

    ((CEdit*)GetDlgItem(IDC_EDITMUSTCONTAIN))->GetWindowText(Str); //获取输入框内容 
    WritePrivateProfileStringW(_T("Edit"), _T("MustConTain"), Str, Oth.GetAppPath() + L"Setting/Config.ini");  //必须包含

    ((CEdit*)GetDlgItem(IDC_EDITCODETOP))->GetWindowText(Str); //获取输入框内容 
    WritePrivateProfileStringW(_T("Edit"), _T("Top"), Str, Oth.GetAppPath() + L"Setting/Config.ini");  //

    ((CEdit*)GetDlgItem(IDC_EDITCODEEND))->GetWindowText(Str); //获取输入框内容 
    WritePrivateProfileStringW(_T("Edit"), _T("CodeEnd"), Str, Oth.GetAppPath() + L"Setting/Config.ini");  //结尾

    ((CEdit*)GetDlgItem(IDC_EDITCODEMIN))->GetWindowText(Str); //获取输入框内容 
    WritePrivateProfileStringW(_T("Edit"), _T("Min"), Str, Oth.GetAppPath() + L"Setting/Config.ini");  //最小长度 

    ((CEdit*)GetDlgItem(IDC_EDITCODEMAX))->GetWindowText(Str); //获取输入框内容 
    WritePrivateProfileStringW(_T("Edit"), _T("Max"), Str, Oth.GetAppPath() + L"Setting/Config.ini");  //最大长度 

    ((CEdit*)GetDlgItem(IDC_EDITCODETEST))->GetWindowText(Str); //获取输入框内容 
    WritePrivateProfileStringW(_T("Edit"), _T("Test"), Str, Oth.GetAppPath() + L"Setting/Config.ini");  //测试

}
//关闭窗体
void CFiltration::OnDestroy()
{
    OnBnClickedBtnsave();
}
//保存按钮
void CFiltration::OnBnClickedBtnsave()
{
    CString CStr;
    ((CEdit*)GetDlgItem(IDC_Name_Filtration1))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Name_Filtration1"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Name_Filtration2))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Name_Filtration2"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Name_Filtration3))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Name_Filtration3"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Name_Filtration4))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Name_Filtration4"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Name_Filtration5))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Name_Filtration5"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Name_Filtration6))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Name_Filtration6"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Name_Filtration7))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Name_Filtration7"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Name_Filtration8))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Name_Filtration8"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Name_Filtration9))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Name_Filtration9"), CStr, ConfigPath);

    ((CEdit*)GetDlgItem(IDC_Name_Filtration21))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Name_Filtration21"), CStr, ConfigPath);

    ((CEdit*)GetDlgItem(IDC_Key_Filtration1))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Key_Filtration1"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Key_Filtration2))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Key_Filtration2"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Key_Filtration3))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Key_Filtration3"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Key_Filtration4))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Key_Filtration4"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Key_Filtration5))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Key_Filtration5"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Key_Filtration6))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Key_Filtration6"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Key_Filtration7))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Key_Filtration7"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Key_Filtration8))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Key_Filtration8"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_Key_Filtration9))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Key_Filtration9"), CStr, ConfigPath);

    ((CEdit*)GetDlgItem(IDC_Key_Filtration21))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Key_Filtration21"), CStr, ConfigPath);

    ((CEdit*)GetDlgItem(IDC_RegExp_Filtration1))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_RegExp_Filtration1"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_RegExp_Filtration2))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_RegExp_Filtration2"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_RegExp_Filtration3))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_RegExp_Filtration3"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_RegExp_Filtration4))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_RegExp_Filtration4"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_RegExp_Filtration5))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_RegExp_Filtration5"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_RegExp_Filtration6))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_RegExp_Filtration6"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_RegExp_Filtration7))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_RegExp_Filtration7"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_RegExp_Filtration8))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_RegExp_Filtration8"), CStr, ConfigPath);
    ((CEdit*)GetDlgItem(IDC_RegExp_Filtration9))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_RegExp_Filtration9"), CStr, ConfigPath);
  
    ((CEdit*)GetDlgItem(IDC_RegExp_Filtration21))->GetWindowText(CStr); WritePrivateProfileStringW(_T("Filtration"), _T("IDC_RegExp_Filtration21"), CStr, ConfigPath);
    SaveGetIni(); //生成正则
    AtCodeMasterDlg* m_B = (AtCodeMasterDlg*)GetParent();
    m_B->GetConfigRegExp();//主窗体更新配置参数
}

//名称
void CFiltration::OnEnChangeNameFiltration1()
{
}
void CFiltration::OnEnChangeNameFiltration2()
{
}
void CFiltration::OnEnChangeNameFiltration3()
{
}
void CFiltration::OnEnChangeNameFiltration4()
{
}
void CFiltration::OnEnChangeNameFiltration5()
{
}
void CFiltration::OnEnChangeNameFiltration6()
{
}
void CFiltration::OnEnChangeNameFiltration7()
{
}
void CFiltration::OnEnChangeNameFiltration8()
{
}
void CFiltration::OnEnChangeNameFiltration9()
{
}
//标志
void CFiltration::OnEnChangeKeyFiltration1()
{
}
void CFiltration::OnEnChangeKeyFiltration2()
{
}
void CFiltration::OnEnChangeKeyFiltration3()
{
}
void CFiltration::OnEnChangeKeyFiltration4()
{
}
void CFiltration::OnEnChangeKeyFiltration5()
{
}
void CFiltration::OnEnChangeKeyFiltration6()
{
}
void CFiltration::OnEnChangeKeyFiltration7()
{
}
void CFiltration::OnEnChangeKeyFiltration8()
{
}
void CFiltration::OnEnChangeKeyFiltration9()
{
}
//勾选
void CFiltration::OnBnClickedCheckFiltration1()
{
    if (((CButton*)GetDlgItem(IDC_Check_Filtration1))->GetCheck() == 1)
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration1"), _T("1"), ConfigPath);
    else
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration1"), _T("0"), ConfigPath);
}
void CFiltration::OnBnClickedCheckFiltration2()
{
    if (((CButton*)GetDlgItem(IDC_Check_Filtration2))->GetCheck() == 1)
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration2"), _T("1"), ConfigPath);
    else
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration2"), _T("0"), ConfigPath);
}
void CFiltration::OnBnClickedCheckFiltration3()
{
    if (((CButton*)GetDlgItem(IDC_Check_Filtration3))->GetCheck() == 1)
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration3"), _T("1"), ConfigPath);
    else
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration3"), _T("0"), ConfigPath);
}
void CFiltration::OnBnClickedCheckFiltration4()
{
    if (((CButton*)GetDlgItem(IDC_Check_Filtration4))->GetCheck() == 1)
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration4"), _T("1"), ConfigPath);
    else
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration4"), _T("0"), ConfigPath);
}
void CFiltration::OnBnClickedCheckFiltration5()
{
    if (((CButton*)GetDlgItem(IDC_Check_Filtration5))->GetCheck() == 1)
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration5"), _T("1"), ConfigPath);
    else
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration5"), _T("0"), ConfigPath);
}
void CFiltration::OnBnClickedCheckFiltration6()
{
    if (((CButton*)GetDlgItem(IDC_Check_Filtration6))->GetCheck() == 1)
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration6"), _T("1"), ConfigPath);
    else
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration6"), _T("0"), ConfigPath);
}
void CFiltration::OnBnClickedCheckFiltration7()
{
    if (((CButton*)GetDlgItem(IDC_Check_Filtration7))->GetCheck() == 1)
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration7"), _T("1"), ConfigPath);
    else
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration7"), _T("0"), ConfigPath);
}
void CFiltration::OnBnClickedCheckFiltration8()
{
    if (((CButton*)GetDlgItem(IDC_Check_Filtration8))->GetCheck() == 1)
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration8"), _T("1"), ConfigPath);
    else
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration8"), _T("0"), ConfigPath);
} 
void CFiltration::OnBnClickedCheckFiltration9()
{
    if (((CButton*)GetDlgItem(IDC_Check_Filtration9))->GetCheck() == 1)
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration9"), _T("1"), ConfigPath);
    else
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration9"), _T("0"), ConfigPath);
}

//过滤规则
void CFiltration::OnEnChangeRegexpFiltration1()
{
}
void CFiltration::OnEnChangeRegexpFiltration2()
{
} 
void CFiltration::OnEnChangeRegexpFiltration3()
{
}
void CFiltration::OnEnChangeRegexpFiltration4()
{
}
void CFiltration::OnEnChangeRegexpFiltration5()
{
}
void CFiltration::OnEnChangeRegexpFiltration6()
{
}
void CFiltration::OnEnChangeRegexpFiltration7()
{
}
void CFiltration::OnEnChangeRegexpFiltration8()
{
}
void CFiltration::OnEnChangeRegexpFiltration9()
{
}

//生成正则勾选
void CFiltration::OnBnClickedCheckFiltration21()
{
    if (((CButton*)GetDlgItem(IDC_Check_Filtration21))->GetCheck() == 1)
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration21"), _T("1"), ConfigPath);
    else
        WritePrivateProfileStringW(_T("Filtration"), _T("IDC_Check_Filtration21"), _T("0"), ConfigPath);
}
//名称
void CFiltration::OnEnChangeNameFiltration21()
{
}
//标志
void CFiltration::OnEnChangeKeyFiltration21()
{
}
//内容 
void CFiltration::OnEnChangeRegexpFiltration21()
{
}


//中通自动获取
void CFiltration::OnBnClickedCheckFiltrationauto2()
{
    if (((CButton*)GetDlgItem(IDC_Check_FiltrationAuto2))->GetCheck() == 1)
        WritePrivateProfileStringW(_T("FiltrationAuto"), _T("IDC_Check_FiltrationAuto2"), _T("1"), ConfigPath);
    else
        WritePrivateProfileStringW(_T("FiltrationAuto"), _T("IDC_Check_FiltrationAuto2"), _T("0"), ConfigPath);
}
//公司缩写
void CFiltration::OnEnChangeEditFiltrationappid2()
{
    CString CStr;
    ((CEdit*)GetDlgItem(IDC_Edit_FiltrationAppId2))->GetWindowText(CStr); WritePrivateProfileStringW(_T("FiltrationAuto"), _T("IDC_Edit_FiltrationAppId2"), CStr, ConfigPath);
}
//密钥
void CFiltration::OnEnChangeEditFiltrationkey2()
{
    CString CStr;
    ((CEdit*)GetDlgItem(IDC_Edit_FiltrationKey2))->GetWindowText(CStr); WritePrivateProfileStringW(_T("FiltrationAuto"), _T("IDC_Edit_FiltrationKey2"), CStr, ConfigPath);
}
//URL 
void CFiltration::OnEnChangeEditFiltrationurl2()
{
    CString CStr;
    ((CEdit*)GetDlgItem(IDC_Edit_FiltrationUrl2))->GetWindowText(CStr); WritePrivateProfileStringW(_T("FiltrationAuto"), _T("IDC_Edit_FiltrationUrl2"), CStr, ConfigPath);
}

//折叠对话框的右边
bool Fold = 0; //折叠的时候不执行自适应控件
void CFiltration::OnBnClickedFold0()
{
    Fold = 1;
    CString str;
    GetDlgItemText(IDC_Fold0, str);
    if (str == "<<自定义")
    {
        SetDlgItemText(IDC_Fold0, L"扩展>>");
    }
    else
    {
        SetDlgItemText(IDC_Fold0, L"<<自定义");
    }
    //两个静态变量，存储对话框尺寸信息
    static CRect rectLarge;
    static CRect rectSmall;
    //如果还没有填充数值
    if (rectLarge.IsRectNull())
    {
        CRect rectSeparator;
        //获取完整对话框位置参数
        GetWindowRect(&rectLarge);
        //获取图像控件的位置参数（有用的是right）
        GetDlgItem(IDC_SEPARATOR)->GetWindowRect(&rectSeparator);
        rectSmall.left = rectLarge.left;
        rectSmall.top = rectLarge.top;
        rectSmall.right = rectSeparator.right;//替换新值
        rectSmall.bottom = rectLarge.bottom;
    }
    if (str == "<<自定义")
    {
        SetWindowPos(NULL, 0, 0, rectSmall.Width(), rectSmall.Height(), SWP_NOMOVE | SWP_NOZORDER); //显示“简化版”对话框
    }
    else
    {
        SetWindowPos(NULL, 0, 0, rectLarge.Width(), rectLarge.Height(), SWP_NOMOVE | SWP_NOZORDER);  //显示“完整版”对话框
    }
    Fold = 0;
}

void CFiltration::OnSize(UINT nType, int cx, int cy)
{
    CDialogEx::OnSize(nType, cx, cy);
    if (nType != SIZE_MINIMIZED)
    {
        Sleep(100);
        if (Fold == 0)
        {
            double fsp[2]{};
            POINT Newp{}; //获取现在对话框的大小
            CRect recta;
            GetClientRect(&recta);     //取客户区大小
            Newp.x = recta.right - recta.left;
            Newp.y = recta.bottom - recta.top;
            fsp[0] = (double)Newp.x / old.x;
            fsp[1] = (double)Newp.y / old.y;
            CRect Rect;
            int woc;
            CPoint OldTLPoint, TLPoint; //左上角
            CPoint OldBRPoint, BRPoint; //右下角
            HWND  hwndChild = ::GetWindow(m_hWnd, GW_CHILD);  //列出所有控件  GW_CHILD
            while (hwndChild)
            {
                woc = ::GetDlgCtrlID(hwndChild);//取得ID
                GetDlgItem(woc)->GetWindowRect(Rect);
                ScreenToClient(Rect);
                OldTLPoint = Rect.TopLeft();
                TLPoint.x = long(OldTLPoint.x * fsp[0]);
                TLPoint.y = long(OldTLPoint.y * fsp[1]);
                OldBRPoint = Rect.BottomRight();
                BRPoint.x = long(OldBRPoint.x * fsp[0]);
                BRPoint.y = long(OldBRPoint.y * fsp[1]);
                Rect.SetRect(TLPoint, BRPoint);
                GetDlgItem(woc)->MoveWindow(Rect, TRUE);
                hwndChild = ::GetWindow(hwndChild, GW_HWNDNEXT); //GW_HWNDNEXT
            }
            old = Newp;
            Invalidate();//更新窗口
        }
    }
}

